#ifndef _OSTREAMER_HPP_20120411
#define _OSTREAMER_HPP_20120411

#include "base.hpp"
#include "bits.hpp"
#include "listbuffer.hpp"
#include "type_trait.hpp"

namespace buffer
{
	class OStreamer
	{
		public :
			OStreamer(ListBuffer & listbuffer)
				: _list_buffer(listbuffer)
			{
			}

		public :
			ListBuffer & _list_buffer;

		private :
			OStreamer(const OStreamer &);
			OStreamer & operator = (const OStreamer &);
	};

	template <typename _T>
		OStreamer & operator & (OStreamer & streamer, const _T & val)
		{
			if (TypeTrait<_T>::base_type)
			{
				buffer::bits::put(_list_buffer, val);
			}
			else
			{
				val.serialize(streamer);
			}

			return streamer;
		}
};

#endif

